import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution1237 {

    static class CustomFunction {
         public int f(int x, int y){
             return x+y;
         }
    }

    public List<List<Integer>> findSolution(CustomFunction customfunction, int z) {
        int x=1,y=1000;
        List<List<Integer>> lists=new ArrayList<>();
        while (x<=1000 && y>0){
            if (customfunction.f(x,y)==z){
                lists.add(Arrays.asList(x,y));
                x++;
            }else if (customfunction.f(x,y)>z){
                y--;
            }else {
                x++;
            }
        }
        return lists;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1237().findSolution(new CustomFunction(),5));
    }
}
